<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="cadastro.css" />
		<script type="text/javascript" src="cadastro.js">
		</script>
		<title></title>
	</head>
	<body>
		<div id="logout">
			<ul>
				<a href="index.php"><li>Página inicial</a></li>
				<a href="<?php #echo "autenticar.php?acao=logout"?>"><li>Sair</a></li>
			</ul>
		</div>
		<div id="form_cadastro">
			<form action="" method="POST" onsubmit="return validaForm(this);">
				<table>
					<tr>
						<td class="td_texto">Novo Usuário</td>
						<td><input type="text" class="form" name="novo_usuario"/></td>
					</tr>
					<tr>
						<td class="td_texto">Senha</td>
						<td><input type="password" class="form" name="senha"/></td>
					</tr>
					<tr>
						<td class="td_texto">Primeiro Nome</td>
						<td><input type="text" class="form" name="prim_nome"/></td>
					</tr>
					<tr>
						<td class="td_texto">Sobrenome</td>
						<td><input type="text" class="form" name="sb_nome"/></td>
					</tr>
					<tr>
						<td class="td_texto">Nome completo</td>
						<td><input type="text" class="form" name="comp_nome"></td>
					</tr>
					<tr>
						<td class="td_texto">Departamento</td>
						<td><input type="text" class="form" name="depart"></td>
					</tr>
					<!-- <tr>
						<td class="td_texto">E-mail</td>
						<td><input type="text" class="form" name="email"></td>
					</tr> -->
					<tr>
						<td class="td_texto">Telefone</td>
						<td><input type="text" class="form" name="phone"></td>
					</tr>
					<tr>
						<td class="td_texto">Ramal</td>
						<td><input type="text" class="form" name="ramal"></td>
					</tr>
					<tr>
						<td class="td_texto">Grupo</td>
						<td><select name="listar_grupos[]" multiple>
							<?php
								$cmd = 'sudo net groupmap list';
								$op;
								$r;
								exec($cmd, $op, $r);
								foreach ($op as $v){
									$grupo = explode(" (", $v);
									echo "<option value=\"$grupo[0]\">". $grupo[0] . "</option>";
								}
							?>
						</select></td>
					</tr>
					<tr>
						<td class="td_texto">Desabilitar usuário</td>
						<td><input type="checkbox" id="checkbox" name="desabilitar_usuario" value="-I"/></td>
					</tr>
					<tr>
						<td colspan=2 class="td_texto">O usuário pode modificar a senha?</td>
					</tr>
					<tr>
						<td style="float:right">Sim<input type="radio" name="senha_radio" value="1"/></td>
						<td style="text-align:center">Nao<input type="radio" name="senha_radio" value="0"/></td>
					</tr>
					<tr>
						<td class="td_texto">Selecionar o Home</td>
						<td><select name="diretorio">
							<option value="H:">H:</option>
							<option value="I:">I:</option>
							<option value="J:">J:</option>
							<option value="K:">K:</option>
							<option value="L:">L:</option>
							<option value="M:">M:</option>
							<option value="N:">N:</option>
							<option value="O:">O:</option>
							<option value="P:">P:</option>
							<option value="Q:">Q:</option>
							<option value="R:">R:</option>
							<option value="S:">S:</option>
							<option value="T:">T:</option>
							<option value="U:">U:</option>
							<option value="V:">V:</option>
							<option value="W:">W:</option>
							<option value="X:">X:</option>
							<option value="Y:">Y:</option>
							<option value="Z:">Z:</option>
						</select></td>
					</tr>
					<tr>
						<td class="td_texto">Logon Script</td>
						<td><input type="text" class="form" name="logon_script"/></td>
					</tr>
					<tr>
						<td></td>
						<td><input type="submit" value="Cadastrar" name="cadastrar"/></td>
					</tr>
				</table>
			</form>
		</div>
		<div id="confirmar_cadastro">
			<form action="cadastrado.php" method="POST">
				<table border=2px>
					<tr>
						<td>Nome</td>
						<td><?php echo $_POST["novo_usuario"];
							?></td>
					</tr>
					<tr>
						<td>Senha</td>
						<td><?php
							$senha = $_POST["senha"];
							echo $senha[0];		
							for ($i=2; $i<strlen($senha); $i++){
								echo "*";
							}
							echo $senha[$i-1];
						?></td>
					</tr>
					<tr>
						<td>Primeiro nome</td>
						<td><?php echo $_POST["prim_nome"];
							?></td>
					</tr>
					<tr>
						<td>Sobrenome</td>
						<td><?php echo $_POST["sb_nome"];
							?></td>
					</tr>
					<tr>
						<td>Nome Completo</td>
						<td><?php echo $_POST["comp_nome"];
							?></td>
					</tr>
					<tr>
						<td>Departamento</td>
						<td><?php echo $_POST["depart"];
							?></td>
					</tr>
					<!-- <tr>
						<td>E-mail</td>
						<td><?php echo $_POST["email"];
							?></td>
					</tr> -->
					<tr>
						<td>Telefone</td>
						<td><?php echo $_POST["phone"];
							?></td>
					</tr>
					<tr>
						<td>Ramal</td>
						<td><?php echo $_POST["ramal"];
							?></td>
					</tr>
					<tr>
						<td>Grupo(s)</td>
						<td><?php
							$grupos = $_POST["listar_grupos"];
							foreach ($grupos as $grupo){
								echo $grupo . ", ";
								echo "<input type=\"hidden\" name=\"list_groups[]\" value=\"$grupo\" />";
							}
						?></td>
					</tr>
					<tr>
						<td>Habilitado?</td>
						<td><?php
							$dsb = $_POST["desabilitar_usuario"];
							if (isset($dsb)){
								echo "Nao";
							}else{
								echo "Sim";
							}
						?></td>
					</tr>
					<tr>
						<td>Modificar a senha</td>
						<td><?php
							$mdfpasswd = $_POST["senha_radio"];
							if ($mdfpasswd == 1){
								echo "Sim";
							}else{
								echo "Nao";
							}
						?></td>
					</tr>	
					<tr>
						<td>Home selecionado</td>
						<td><?php echo $_POST["diretorio"];
							?></td>
					</tr>
					<tr>
						<td>Logon Script</td>
						<td><?php echo $_POST["logon_script"];
							?></td>
					</tr>
				</table>
				<input type="hidden" name="login" value="<?php echo $_POST['novo_usuario'];?>"/>
				<input type="hidden" name="senha" value="<?php echo $_POST['senha'];?>"/>
				<input type="hidden" name="prim_name" value="<?php echo $_POST['prim_nome'];?>"/>
				<input type="hidden" name="sb_name" value="<?php echo $_POST['sb_nome'];?>"/>
				<input type="hidden" name="compl_name" value="<?php echo $_POST['comp_nome'];?>"/>
				<input type="hidden" name="setor" value="<?php echo $_POST['depart'];?>"/>
				<!-- <input type="hidden" name="mail" value="<?php echo $_POST['email'];?>"/ -->
				<input type="hidden" name="telephone" value="<?php echo $_POST['phone'];?>"/>
				<input type="hidden" name="ramal_setor" value="<?php echo $_POST['ramal'];?>"/>
				<input type="hidden" name="dsb" value="<?php echo $_POST['desabilitar_usuario'];?>"/>
				<input type="hidden" name="mdfpasswd" value="<?php echo $_POST['senha_radio'];?>"/>
				<input type="hidden" name="dir" value="<?php echo $_POST['diretorio'];?>"/>
				<input type="hidden" name="log_scr" value="<?php echo $_POST['logon_script'];?>"/>
				<input type="hidden" name="confirmar"/>
				<input type="submit" value="Confirmar"/>
			</form>
		</div>
		<div id="listar_script">
			<p class="td_texto">Lista de Scripts</p>
			<iframe src="list_scr.php"></iframe>	
		</div>
		<div id="footer"></div>
	</body>
</html>
